﻿public class Solution {
    public bool CanJump(int[] nums)
    {
        int canjump = 0;
        for (int i = 0; i <= canjump && i < nums.Length; i++)
        {
            if (nums[i] + i > canjump)
            {
                canjump = i + nums[i];
            }
        }

        if (canjump >= nums.Length - 1) return true;
        return false;
    }

    public static void Main(string[] args)
    {
        int[] nums = [2, 3, 1, 1, 4];

        Solution solution = new Solution();
        bool res = solution.CanJump(nums);
        Console.WriteLine(res);
    }
}